package oralExamSchedulingSystem;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class CSVParser {
	
	public ArrayList < Student > inputParseCsv(String path) throws IOException{
		ArrayList < Student > studentList= new ArrayList < Student > ();
		try{
			BufferedReader CSVFile = new BufferedReader(new FileReader(path));
			
			String dataRow = CSVFile.readLine();
			while (dataRow != null){
				String[] dataArray = dataRow.split(",");
				studentList.add(new Student (Integer.parseInt(dataArray[0].trim()), dataArray[1].trim(),Integer.parseInt(dataArray[2].trim()), dataArray[3].trim(), dataArray[4].trim().charAt(0)));
				dataRow = CSVFile.readLine(); // Read next line of data.
			}
			// Close the file once all data has been read.
			CSVFile.close();

		 }
		 catch(FileNotFoundException e){
			 return null;
			 
		 }
		return studentList;
	}
	
	
	
	public String outputParseCsv(Timetable t){
		return null;
	}
}
